//
//  LXWebPlugin.swift
//  LXReuseTools
//
//  Created by yoctech on 2021/8/12.
//

import Foundation
import WebKit

public class WKScriptMessageHandlerNormal: NSObject {
    
}


extension WKScriptMessageHandlerNormal: WKScriptMessageHandler {
    public func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        if let body :[String:String] = message.body as? [String:String] {
            print(String.init(format: "[WKScriptMessage] name = %@, body = %@", message.name, body))
            let sel = Selector.init(message.name)
            if self.responds(to: sel) {
                self.perform(sel)
            }
        }else{

        }
    }
}
